package bank;
import java.util.Date;
/**
 * @ClassName: bank
 * @Auther: Drawin
 * @Date: 2021/9/27 19:37
 * @Description:
 */

public class bank {
    private String id, name;//账户编号、账户名称
    private double balance;//账户余额
    private Date datetime;//开户时间

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
    public Date getDatetime(){return datetime;}
    public void setDatetime(Date datetime){this.datetime=datetime;}
    public bank(String id,String name,double balance){
        this.id=id;
        this.name=name;
        this.balance=balance;
        this.datetime=new Date();//开户时间采用系统时间
    }
    public bank(){
        this.id="";//id默认为空，需要在main方法中用setId来赋值
        this.name="";//name默认为空，需要在main中用setname赋值
        this.balance=0;//默认为0，开户时没有存入
        this.datetime=new Date();//datetime默认为当前时间
    }
    public void deposite(double money){this.balance=this.balance+money;}//存钱的方法
    public void withdraw(double money){
        if(this.balance<money){
            System.out.println("您的余额不足");
            return;
        }
        this.balance=this.balance-money;//当前账户余额减去money
    }
    public void changeMoney(bank other,double money){
        if(this.balance<money){
            System.out.println("余额不足");
            return;
        }
        this.balance=this.balance-money;
        other.balance=other.balance+money;
    }
    public void print(){
        System.out.println("账号："+id+"户名："+name+"余额"+balance);
    }
}

